package com.wanlian.context.Notice;

import com.wanlian.util.StringUtil;
import com.wanlian.vo.NoticeMsgResultVo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class NoticeCache {
    private int userId;

    private Long preSendTime;

    private List<NoticeMsgResultVo> noticeMsgResultVos;

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public Long getPreSendTime() {
        return preSendTime;
    }

    public void setPreSendTime(Long preSendTime) {
        this.preSendTime = preSendTime;
    }

    public List<NoticeMsgResultVo> getNoticeMsgResultVos() {
        return noticeMsgResultVos;
    }

    public void setNoticeMsgResultVos(List<NoticeMsgResultVo> noticeMsgResultVos) {
        this.noticeMsgResultVos = noticeMsgResultVos;
    }

    public void tidyMsgs() {
        List<NoticeMsgResultVo> sendVos = new ArrayList<>();
        Map<String, NoticeMsgResultVo> maps = new HashMap<>();
        for (NoticeMsgResultVo vo : noticeMsgResultVos) {
            String sourceType = vo.getNoticeMsg().getSourceType();
            if (StringUtil.hasValue(sourceType)) {
                if (maps.containsKey(sourceType)) {
                    //String chref = "多人回复：" + vo.getNoticeMsg().getChref();
                    //vo.getNoticeMsg().setChref(chref);
                } else {
                    maps.put(sourceType, vo);
                    sendVos.add(vo);
                }
            } else {
                sendVos.add(vo);
            }
        }
        this.setNoticeMsgResultVos(sendVos);
    }

}
